# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=flask-marshmallow
_pyname=flask_marshmallow
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.3.0
pkgrel=1
pkgdesc='Flask + marshmallow for beautiful APIs (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-flask-marshmallow'
  'purl: pkg:pypi/flask-marshmallow'
)
msys2_repository_url='https://github.com/marshmallow-code/flask-marshmallow/'
msys2_changelog_url='https://flask-marshmallow.readthedocs.io/en/latest/changelog.html'
msys2_documentation_url='https://flask-marshmallow.readthedocs.io/'
msys2_issue_tracker_url='https://github.com/marshmallow-code/flask-marshmallow/issues'
url='https://github.com/marshmallow-code/flask-marshmallow'
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-flask-sqlalchemy"
         "${MINGW_PACKAGE_PREFIX}-python-marshmallow-sqlalchemy")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-flit-core"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('27a35d0ce5dcba161cc5f2f4764afbc2536c93fa439a793250b827835e3f3be6')

build() {
  cp -r "${_pyname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
